1 // Equipo Poncho, Carriel y Ruana
22 template <class T
> string
toStr(const T
&x
)
23 { stringstream s
; s
<< x
; return s
.str(); }
24 template <class T
> int toInt(const T
&x
)
25 { stringstream s
; s
<< x
; int r
; s
>> r
; return r
; }
27 #define For(i, a, b) for (int i=(a); i<(b); ++i)
28 #define foreach(x, v) for (typeof (v).begin() x = (v).begin(); x != (v).end(); ++x)
29 #define D(x) cout << #x " = " << (x) << endl;
31 const double EPS
= 1e-9;
33 int cmp(double x
, double y
= 0, double tol
= EPS
) {
34 return (x
<= y
+ tol
) ? (x
+ tol
< y
) ? -1 : 0 : 1;
37 #define INPUT_FILE "digital"
40 freopen(INPUT_FILE
".in", "r", stdin
);
42 while (cin
>> n
>> m
) {
43 if (n
== 0 and m
== 0) break;
45 vector
<long long> grad(k
+ 1);
46 for (int i
= 0; i
< k
+ 1; ++i
) {
49 long long mod
= n
+ 1;
50 //assert(grad.size() == k + 1);
52 for (long long x
= 0; x
<= m
; x
++){
55 for (int i
= 0; i
< grad
.size(); ++i
) {
56 //printf(" y = y + %d\n", grad[i] * d);
57 y
+= ((grad
[i
] % mod
) * d
) % mod
;
59 d
= (d
* (x
% mod
)) % mod
;
62 //printf("added %d\n", y % mod);
64 cout
<< ans
.size() << endl
;